using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Calendar.UI
{
    public partial class frmAlertBehindSchedule : Form
    {
        DataTable dtTasks;
        int i4dtTasks = 0;

        public frmAlertBehindSchedule(DataTable dt)
        {
            InitializeComponent();
            this.dtTasks = dt;
        }

        public frmAlertBehindSchedule()
        {
            InitializeComponent();
        }

        private void frmAlertBehindSchedule_Load(object sender, EventArgs e)
        {
            grpTask.Text = "Showing 1 of " + dtTasks.Rows.Count + " Task(s)";
            ShowTaskDetail();
            this.WindowState = FormWindowState.Normal;
            GlobalInfo.AlertFabsShownOnce = true;
        }

        private void ShowTaskDetail()
        {
            txtPrj.Text = dtTasks.Rows[i4dtTasks]["projectname"].ToString();
            txtMilestone.Text = dtTasks.Rows[i4dtTasks]["milestone"].ToString();
            txtPM.Text = dtTasks.Rows[i4dtTasks]["ProjectManager"].ToString();
            txtPriority.Text = dtTasks.Rows[i4dtTasks]["prioritytype"].ToString();
            txtSummary.Text = dtTasks.Rows[i4dtTasks]["ShortSummary"].ToString();
            //txtDesc.Text = dtTasks.Rows[i4dtTasks]["Description"].ToString();
            txtStartDate.Text = Convert.ToDateTime(dtTasks.Rows[i4dtTasks]["startdate"].ToString()).ToString("dd-MMM-yyyy hh:mm");
            txtEndDate.Text = Convert.ToDateTime(dtTasks.Rows[i4dtTasks]["estimatedEndDate"].ToString()).ToString("dd-MMM-yyyy  hh:mm");
            txtAssignTo.Text = dtTasks.Rows[i4dtTasks]["AssignedTo"].ToString();
            txtToday.Text = DateTime.Now.ToString("dd-MMM-yyyy");
        }

        private void btnNext_Click(object sender, EventArgs e)
        {
            if (i4dtTasks < dtTasks.Rows.Count - 1) { i4dtTasks++; } //btnPrevious.Enabled = true; 
            ShowTaskDetail();
            grpTask.Text = "Showing " + (i4dtTasks + 1) + " of " + dtTasks.Rows.Count + " Task(s)";
        }

        private void btnPrevious_Click(object sender, EventArgs e)
        {
            if (i4dtTasks > 0) { i4dtTasks--; }
            ShowTaskDetail();
            grpTask.Text = "Showing " + (i4dtTasks + 1) + " of " + dtTasks.Rows.Count + " Task(s)";
        }

        private void btnClose_Click(object sender, EventArgs e)
        {
            frmAlertController.fabs = null;
            this.Dispose();
        }

        private void btnOk_Click(object sender, EventArgs e)
        {
            frmAlertController.fabs = null;
            this.Dispose();
        }

        private void btnDisableTemp_Click(object sender, EventArgs e)
        {
            InputBoxResult test = InputBox.Show("Please enter no of days for which you want to disable alerts", "Disable alerts temporarily");
            if (test.ReturnCode == DialogResult.OK)
                MessageBox.Show(test.Text);
            // set disableUptoThisDate = curr_date + test.Text (input of days)
        }

        private void btnDisableToday_Click(object sender, EventArgs e)
        {
            // set disableUptoThisDate = curr_date  => before showing alert, check if currdate is equal to disableUptoThisDate, if yes, dont show alert
        }

        private void btnDisable4Ever_Click(object sender, EventArgs e)
        {
          // add 50 years to this disableUptoThisDate, for this loginId
        }


    }
}